home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / osrc.arc / GLOBAL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-05  |  3.8 KB  |  147 lines

  1. #ifndef    MAXINT16
  2.  
  3. /* Global definitions used by every source file.
  4.  * Some may be compiler dependent.
  5.  */
  6.  
  7. #if    (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  8. /* These compilers require special open modes when reading binary files.
  9.  * 
  10.  * "The single most brilliant design decision in all of UNIX was the
  11.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  12.  *
  13.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  14.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  15.  */
  16. #define    READ_BINARY    "rb"
  17. #define    WRITE_BINARY    "wb"
  18. #define    READ_TEXT    "rt"
  19. #define    WRITE_TEXT    "wt"
  20. #define    APPEND_TEXT    "at+"
  21.  
  22. #else
  23.  
  24. #define    READ_BINARY    "r"
  25. #define    WRITE_BINARY    "w"
  26. #define    READ_TEXT    "r"
  27. #define    WRITE_TEXT    "w"
  28. #define    APPEND_TEXT    "a+"
  29.  
  30. #endif
  31.  
  32.  
  33. /* These two lines assume that your compiler's longs are 32 bits and
  34.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  35.  * but it doesn't matter if they're signed or unsigned.
  36.  */
  37. typedef long int32;        /* 32-bit signed integer */
  38. typedef unsigned short int16;    /* 16-bit unsigned integer */
  39. #define    uchar(x) ((unsigned char)(x))
  40. #define    MAXINT16 65535        /* Largest 16-bit integer */
  41.  
  42. #if    (sizeof(int (*)()) == 4)
  43. #define    LARGECODE    1
  44. #endif
  45.  
  46. #if    (sizeof(int *) == 4)
  47. #define    LARGEDATA    1
  48. #endif
  49.  
  50. /* Since not all compilers support structure assignment, the ASSIGN()
  51.  * macro is used. This controls how it's actually implemented.
  52.  */
  53. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  54. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  55. #else            /* Version for compilers that do */
  56. #define    ASSIGN(a,b)    ((a) = (b))
  57. #endif
  58.  
  59. /* Define null object pointer in case stdio.h isn't included */
  60. #ifndef    NULL
  61. /* General purpose NULL pointer */
  62. #define    NULL (void *)0
  63. #endif
  64. #define    NULLCHAR (char *)0    /* Null character pointer */
  65. #define    NULLCHARP (char **)0    /* Null character pointer pointer */
  66. #define    NULLINT    (int *)0    /* Null integer pointer */
  67. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  68. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  69. #define    NULLVIFP (void interrupt (*)())0
  70. #define    NULLFILE (FILE *)0    /* Null file pointer */
  71.  
  72.  
  73. #ifdef    MPU8080    /* Assembler routines are available */
  74. int16 hinibble(),lonibble(),hibyte(),lobyte(),hiword(),loword();
  75.  
  76. #else
  77.  
  78. /* Extract a short from a long */
  79. #define    hiword(x)    ((int16)((x) >> 16))
  80. #define    loword(x)    ((int16)(x))
  81.  
  82. /* Extract a byte from a short */
  83. #define    hibyte(x)    ((unsigned char)((x) >> 8))
  84. #define    lobyte(x)    ((unsigned char)(x))
  85.  
  86. /* Extract nibbles from a byte */
  87. #define    hinibble(x)    (((x) >> 4) & 0xf)
  88. #define    lonibble(x)    ((x) & 0xf)
  89.  
  90. #endif
  91.  
  92. /* Local subroutines */
  93. #if    defined(__STDC__) || defined (__TURBOC__)
  94.  
  95. int htoi(char *);
  96. long htol(char *);
  97. void rip(char *);
  98. int dirps(void);
  99. void restore(int);
  100. long ptol(void *);
  101. #if    !defined(__STDC__)
  102. long hptol(void huge *);
  103. #endif
  104. void *ltop(long);
  105. #if    !defined(__TURBOC__)
  106. char *strdup(const char *);
  107. #endif
  108.  
  109. #else
  110.  
  111. int htoi();
  112. long htol();
  113. void rip();
  114. int dirps();
  115. void restore();
  116. long ptol();
  117. void *ltop();
  118. #if    !defined(__TURBOC__)
  119. char *strdup();
  120. #endif
  121.  
  122. #endif    /* defined(__STDC__) || defined (__TURBOC__) */
  123.  
  124. #include <stdlib.h>
  125. #include <string.h>
  126.  
  127. #ifdef    AZTEC
  128. #define    rewind(fp)    fseek(fp,0L,0);
  129. #endif
  130.  
  131. #ifdef    __TURBOC__
  132. #define movblock(so,ss,do,ds,c)    movedata(ss,so,ds,do,c)
  133. #define outportw outport
  134. #define inportw inport
  135.  
  136. #else
  137.  
  138. /* General purpose function macros already defined in turbo C */
  139. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  140. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  141. #define MK_FP(seg,ofs)    ((void far *) \
  142.                (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  143. #endif    /* defined(__TURBOC __) */
  144.  
  145. #endif    /* MAXINT16 */
  146.  
  147.